{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=507
  Verdict: Accepted
}
{$APPTYPE CONSOLE}
{$R+,S+,Q+,I+,O-}
uses SysUtils;
type ar=array[-1..300] of longint;
var n,i,j,r,k:longint; a,b:ar; f,g:boolean;
function check(a:ar; n:longint):boolean;
var i:longint;
begin
result:=true;
for i:=1 to n div 2 do
  if a[i]<>a[n-i+1] then result:=false;
end;
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
readln(n);
for i:=1 to n do read(a[i]);
if not check(a,n) then begin
  r:=0;
  for i:=n div 2+1 to n do begin
    for j:=1 to i do b[j]:=a[j];
    k:=i;
    for j:=i-1 downto 1 do begin
      inc(k);
      b[k]:=a[j];
    end;
    f:=true;
    for j:=i+1 to n do if b[j]<>a[j] then f:=false;
    g:=false;
    if f then begin
      if check(b,i+i-1) then begin
        writeln(i-1-n+i);
        for j:=i+i-1-n downto 1 do write(a[j],' ');
        break;
      end else g:=true;
    end else g:=true;
    if g then begin
      for j:=1 to i do b[j]:=a[j];
      k:=i;
      for j:=i downto 1 do begin
        inc(k);
        b[k]:=a[j];
      end;
      f:=true;
      for j:=i+1 to n do if b[j]<>a[j] then f:=false;
      if (check(b,i+i)) and (f) then begin
        writeln(i-n+i);
        for j:=i+i-n downto 1 do write(a[j],' ');
        break;
      end;
    end;
  end;
end else writeln(0);
end.